home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / fax / leffler / v2.1.0.patch-4 < prev    next >
Text File  |  1993-07-19  |  32KB  |  1,152 lines

  1. #! /bin/sh
  2. # patch script for converting a15 to a19
  3. TOP=.
  4.  
  5. Patch()
  6. {
  7.     echo "Patch $1:"; patch -s $TOP/$1
  8. }
  9.  
  10. NewFile()
  11. {
  12.     echo "New file $1"; cat >$TOP/$1
  13. }
  14.  
  15. NewDir()
  16. {
  17.     echo "New directory $1"; mkdir $TOP/$1
  18. }
  19.  
  20. RmFile()
  21. {
  22.     echo "Remove $1"; rm -f $TOP/$1.orig; mv $TOP/$1 $TOP/$1.orig
  23. }
  24.  
  25. Patch MODEMS<<'EOF-EOF-EOF'
  26. 1c1
  27. < $Header: /usr/people/sam/fax/RCS/MODEMS,v 1.19 93/05/12 09:08:31 sam Exp $
  28. ---
  29. > $Header: /usr/people/sam/fax/RCS/MODEMS,v 1.20 93/07/15 10:50:26 sam Exp $
  30. 40c40
  31. < o received HDLC frames do NOT include the FCS bytes
  32. ---
  33. > o received HDLC frames do NOT include the FCS bytes (fixed in rev 133).
  34. EOF-EOF-EOF
  35. Patch distrules<<'EOF-EOF-EOF'
  36. 1c1
  37. < #    $Header: /usr/people/sam/fax/RCS/distrules,v 1.62 93/07/11 13:04:08 sam Exp $
  38. ---
  39. > #    $Header: /usr/people/sam/fax/RCS/distrules,v 1.64 93/07/19 11:33:59 sam Exp $
  40. 131d130
  41. <     port/linux/osfcn.h                \
  42. 133c132
  43. <     port/linux/sys/param.h            \
  44. ---
  45. >     port/linux/sys/types.h            \
  46. 260a260
  47. >     util/recvstats.sh            \
  48. 263a264
  49. >     util/xferstats.sh            \
  50. 269,270d269
  51. <     util/xfer.awk                \
  52. <     util/xferdest.awk            \
  53. EOF-EOF-EOF
  54. Patch dist/flexfax.alpha<<'EOF-EOF-EOF'
  55. 1c1
  56. < define ALPHA 015
  57. ---
  58. > define ALPHA 019
  59. EOF-EOF-EOF
  60. Patch faxd/Class2.c++<<'EOF-EOF-EOF'
  61. 1c1
  62. < /*    $Header: /usr/people/sam/fax/faxd/RCS/Class2.c++,v 1.60 93/05/16 11:51:30 sam Exp $
  63. ---
  64. > /*    $Header: /usr/people/sam/fax/faxd/RCS/Class2.c++,v 1.61 93/07/13 11:42:41 sam Exp $
  65. 213,214d212
  66. <  * Note that we do not touch bit rate or min scanline time
  67. <  * because we leave these to the modems to handle.
  68. 220c218
  69. <     params.br = (u_int) -1;
  70. ---
  71. >     params.br = getBestSignallingRate();
  72. 224,226c222,224
  73. <     params.ec = (u_int) -1;
  74. <     params.bf = (u_int) -1;
  75. <     params.st = (u_int) -1;
  76. ---
  77. >     params.ec = EC_DISABLE;        // XXX
  78. >     params.bf = BF_DISABLE;
  79. >     params.st = getBestScanlineTime();
  80. EOF-EOF-EOF
  81. Patch faxd/Class2Send.c++<<'EOF-EOF-EOF'
  82. 1c1
  83. < /*    $Header: /usr/people/sam/fax/faxd/RCS/Class2Send.c++,v 1.56 93/07/09 14:51:00 sam Exp $
  84. ---
  85. > /*    $Header: /usr/people/sam/fax/faxd/RCS/Class2Send.c++,v 1.57 93/07/13 11:45:12 sam Exp $
  86. 145,146d144
  87. <     u_int br = next.br;            // saved for caller use
  88. <     next.br = (u_int) -1;        // put in what's expected below
  89. 157,164d154
  90. <         /*
  91. <          * XXX don't touch these, some modems such as the
  92. <          * ZyXEL get confused and hangup the phone (argh).
  93. <          */
  94. <         next.br = (u_int) -1;
  95. <         next.ec = (u_int) -1;
  96. <         next.bf = (u_int) -1;
  97. <         next.st = (u_int) -1;
  98. 221d210
  99. <     next.br = br;            // restore original
  100. EOF-EOF-EOF
  101. Patch faxd/FaxMachineLog.c++<<'EOF-EOF-EOF'
  102. 1c1
  103. < /*    $Header: /usr/people/sam/fax/faxd/RCS/FaxMachineLog.c++,v 1.9 93/07/09 17:30:28 sam Exp $
  104. ---
  105. > /*    $Header: /usr/people/sam/fax/faxd/RCS/FaxMachineLog.c++,v 1.10 93/07/15 10:25:15 sam Exp $
  106. 110c110
  107. <     vsprintf(buf+strlen(buf), fmt, ap);
  108. ---
  109. >     vsprintf(buf+strlen(buf), (char*) fmt, ap);
  110. EOF-EOF-EOF
  111. Patch faxd/FaxModem.c++<<'EOF-EOF-EOF'
  112. 1c1
  113. < /*    $Header: /usr/people/sam/fax/faxd/RCS/FaxModem.c++,v 1.75 93/06/22 18:21:08 sam Exp $
  114. ---
  115. > /*    $Header: /usr/people/sam/fax/faxd/RCS/FaxModem.c++,v 1.76 93/07/13 17:28:06 sam Exp $
  116. 1004c1004
  117. < FaxModem::recvCSI(const fxStr& csi)
  118. ---
  119. > FaxModem::recvCSI(fxStr& csi)
  120. 1006,1010c1006,1009
  121. <     fxStr s(csi);
  122. <     s.remove(0, s.skip(0,' '));        // strip leading white space
  123. <     u_int pos = s.skipR(s.length(),' ');
  124. <     s.remove(pos, s.length() - pos);    // and trailing white space
  125. <     protoTrace("REMOTE CSI \"%s\"", (char*) s);
  126. ---
  127. >     csi.remove(0, csi.skip(0,' '));    // strip leading white space
  128. >     u_int pos = csi.skipR(csi.length(),' ');
  129. >     csi.remove(pos, csi.length() - pos);// and trailing white space
  130. >     protoTrace("REMOTE CSI \"%s\"", (char*) csi);
  131. EOF-EOF-EOF
  132. Patch faxd/FaxModem.h<<'EOF-EOF-EOF'
  133. 1c1
  134. < /*    $Header: /usr/people/sam/fax/faxd/RCS/FaxModem.h,v 1.66 93/07/09 14:51:02 sam Exp $
  135. ---
  136. > /*    $Header: /usr/people/sam/fax/faxd/RCS/FaxModem.h,v 1.67 93/07/13 17:27:43 sam Exp $
  137. 249c249
  138. <     void    recvCSI(const fxStr&);
  139. ---
  140. >     void    recvCSI(fxStr&);
  141. EOF-EOF-EOF
  142. Patch faxd/FaxSend.c++<<'EOF-EOF-EOF'
  143. 1c1
  144. < /*    $Header: /usr/people/sam/fax/faxd/RCS/FaxSend.c++,v 1.77 93/07/09 18:03:56 sam Exp $
  145. ---
  146. > /*    $Header: /usr/people/sam/fax/faxd/RCS/FaxSend.c++,v 1.81 93/07/19 13:57:41 sam Exp $
  147. 64a65,67
  148. >          *
  149. >          * NB: we fetch the client information here because
  150. >          *     it's needed in preparing the document.
  151. 65a69,70
  152. >         fxStr canon = canonicalizePhoneNumber(fax.number);
  153. >         clientInfo.restore(canon);
  154. 69,71c74,75
  155. <          * Construct the phone number to dial by crafting the
  156. <          * canonical form (+<country><areacode><number>), and
  157. <          * preparing the form to use in dialing the telephone.
  158. ---
  159. >          * Construct the phone number to dial by applying the
  160. >          * dialing rules to the user-specified dialing string.
  161. 73d76
  162. <         fxStr canon = canonicalizePhoneNumber(fax.number);
  163. 106a110
  164. >     u_int pagesSent = npages - fax.npages;
  165. 108a113,114
  166. >     pagesSent,
  167. >     clientInfo.getCSI(),
  168. 139d144
  169. <     clientInfo.restore(canon);
  170. 543c548,549
  171. <         "REJECT: %s, max remote page width %u, image width %lu",
  172. ---
  173. >         "REJECT: %s, max remote page width %u pixels"
  174. >          ", image width %lu pixels",
  175. 576c582
  176. <         "REJECT: %s, image resolution %g line/mm",
  177. ---
  178. >         "REJECT: %s, image resolution %g lines/mm",
  179. 599,600c605,607
  180. <         "REJECT: %s, max remote page length %d, image length %lu",
  181. <         (char*) emsg, clientInfo.getMaxPageLength(), h);
  182. ---
  183. >         "REJECT: %s, max remote page length %d mm"
  184. >             ", image length %lu rows (%.2f mm)",
  185. >         (char*) emsg, clientInfo.getMaxPageLength(), h, len);
  186. EOF-EOF-EOF
  187. Patch faxd/faxServerApp.c++<<'EOF-EOF-EOF'
  188. 1c1
  189. < /*    $Header: /usr/people/sam/fax/faxd/RCS/faxServerApp.c++,v 1.109 93/07/09 18:27:57 sam Exp $
  190. ---
  191. > /*    $Header: /usr/people/sam/fax/faxd/RCS/faxServerApp.c++,v 1.112 93/07/19 13:58:18 sam Exp $
  192. 793a794,806
  193. > struct FaxAcctInfo {
  194. >     const char*    user;        // sender/receiver identity
  195. >     time_t    start;        // starting time
  196. >     time_t    duration;    // job duration (minutes)
  197. >     const char*    device;        // modem device
  198. >     const char*    dest;        // receiver phone number
  199. >     const char*    csi;        // remote csi
  200. >     u_int    npages;        // pages successfully sent/rcvd
  201. >     u_int    sigrate;    // negotiated signalling rate
  202. >     const char*    df;        // negotiated data format
  203. >     const char*    status;        // status info (optional)
  204. > };
  205. 798c811,812
  206. < faxServerApp::notifySendDone(FaxRequest* req, u_int sigrate, const char* protocol)
  207. ---
  208. > faxServerApp::notifySendDone(FaxRequest* req,
  209. >     u_int npages, const char* csi, u_int sigrate, const char* df)
  210. 801,803c815,825
  211. <     time_t now = time(0);
  212. <     float dt = (now - jobStart) / 60.;
  213. <     const char* reason = req->notice;
  214. ---
  215. >     FaxAcctInfo ai;
  216. >     ai.user = req->mailaddr;
  217. >     ai.start = jobStart;
  218. >     ai.duration = time(0) - jobStart;
  219. >     ai.device = devID;
  220. >     ai.dest = req->number;
  221. >     ai.csi = csi;
  222. >     ai.npages = npages;
  223. >     ai.sigrate = sigrate;
  224. >     ai.df = df;
  225. >     ai.status = req->notice;
  226. 805,807c827,828
  227. <         reason = "";
  228. <     record("SEND", req->mailaddr, req->number,
  229. <         sigrate, protocol, req->npages, dt, reason);
  230. ---
  231. >         ai.status = "";
  232. >     account("SEND", ai);
  233. 1287,1288c1308,1320
  234. <     record("RECV", ri.sender, server->getModemNumber(),
  235. <     ri.sigrate, ri.protocol, ri.npages, ri.time / 60., ri.reason);
  236. ---
  237. >     FaxAcctInfo ai;
  238. >     ai.user = "fax";
  239. >     ai.duration = (time_t) ri.time;
  240. >     ai.start = time(0) - ai.duration;
  241. >     ai.device = devID;
  242. >     ai.dest = server->getModemNumber();
  243. >     ai.csi = ri.sender;
  244. >     ai.npages = ri.npages;
  245. >     ai.sigrate = ri.sigrate;
  246. >     ai.df = ri.protocol;
  247. >     ai.status = ri.reason;
  248. >     account("RECV", ai);
  249. 1507c1539,1540
  250. <     *cp++ = digits[v / 10];
  251. ---
  252. >     if (v >= 10)
  253. >         *cp++ = digits[v / 10];
  254. 1513c1546
  255. <     if (v > 10 || cp > tbuf)
  256. ---
  257. >     if (v >= 10 || cp > tbuf)
  258. 1567,1571c1600
  259. < faxServerApp::record(const char* cmd,
  260. <     const char* from, const char* to,
  261. <     int sigrate, const char* protocol,
  262. <     int npages, float duration,
  263. <     const char* reason)
  264. ---
  265. > faxServerApp::account(const char* cmd, const FaxAcctInfo& ai)
  266. 1576d1604
  267. <     time_t now = time(0);
  268. 1578,1580c1606,1614
  269. <     strftime(buf, sizeof (buf), "%D %R", localtime(&now));
  270. <     fprintf(flog, "%s\t%s\t\"%s\"\t\"%s\"\t%d\t\"%s\"\t%d\t%.2f\t\"%s\"\n",
  271. <         buf, cmd, from, to, sigrate, protocol, npages, duration, reason);
  272. ---
  273. >     strftime(buf, sizeof (buf), "%D %R", localtime(&ai.start));
  274. >     fprintf(flog,
  275. >         "%s\t%s\t%s\t%s\t\"%s\"\t\"%s\"\t%d\t%s\t%d\t%s\t\"%s\"\n",
  276. >         buf, cmd, ai.device,
  277. >         ai.user,
  278. >         ai.dest, ai.csi,
  279. >         ai.sigrate, ai.df,
  280. >         ai.npages, fmtTime(ai.duration),
  281. >         ai.status);
  282. EOF-EOF-EOF
  283. Patch faxd/faxServerApp.h<<'EOF-EOF-EOF'
  284. 1c1
  285. < /*    $Header: /usr/people/sam/fax/faxd/RCS/faxServerApp.h,v 1.39 93/07/09 18:04:35 sam Exp $
  286. ---
  287. > /*    $Header: /usr/people/sam/fax/faxd/RCS/faxServerApp.h,v 1.41 93/07/19 13:58:19 sam Exp $
  288. 94c94
  289. <     time_t    fileStart;        // starting time for file
  290. ---
  291. >     time_t    fileStart;        // starting time for file/poll
  292. 119,123c119
  293. <     void    record(const char* cmd,
  294. <             const char* from, const char* to,
  295. <             int rate, const char* protocol,
  296. <             int npages, float time,
  297. <             const char* reason);
  298. ---
  299. >     void    account(const char* cmd, const struct FaxAcctInfo&);
  300. 176c172,173
  301. <     void    notifySendDone(FaxRequest* req, u_int sigrate, const char* protoocol);
  302. ---
  303. >     void    notifySendDone(FaxRequest* req, u_int npages,
  304. >             const char* csi, u_int sigrate, const char* df);
  305. EOF-EOF-EOF
  306. Patch gs/gdevtiff.c<<'EOF-EOF-EOF'
  307. 1c1
  308. < /* $Header: /usr/people/sam/fax/gs/RCS/gdevtiff.c,v 1.4 93/07/06 21:11:00 sam Exp $ */
  309. ---
  310. > /* $Header: /usr/people/sam/fax/gs/RCS/gdevtiff.c,v 1.6 93/07/19 08:20:44 sam Exp $ */
  311. 136c136
  312. <     { 85,  117, 1728 },
  313. ---
  314. >     { 85,  116, 1728 },
  315. 171c171
  316. <     ddev->fax.iwidth = pi->iw;
  317. ---
  318. >     ddev->fax->iwidth = pi->iw;
  319. EOF-EOF-EOF
  320. Patch man/textfmt.1<<'EOF-EOF-EOF'
  321. 1c1
  322. < .\"    $Header: /usr/people/sam/fax/man/RCS/textfmt.1,v 1.3 93/07/08 17:06:43 sam Exp $
  323. ---
  324. > .\"    $Header: /usr/people/sam/fax/man/RCS/textfmt.1,v 1.4 93/07/16 10:14:06 sam Exp $
  325. 150c150
  326. < this file will almost certainly result
  327. ---
  328. > this metric will almost certainly result
  329. EOF-EOF-EOF
  330. Patch port/linux/README<<'EOF-EOF-EOF'
  331. 6,7c6,7
  332. <     - the kernel needs two small big fixes.  See the file
  333. <       kernel.diffs for details.  From the directory in which
  334. ---
  335. >     - the kernel needs a small bug fix.  See the file
  336. >       kernel.patch for details.  From the directory in which
  337. 10c10
  338. <       These fixes are needed for versions <= 99p10.
  339. ---
  340. >       This fix is needed for versions <= 99p10.
  341. EOF-EOF-EOF
  342. Patch port/linux/kernel.patch<<'EOF-EOF-EOF'
  343. 1c1
  344. < Two small bug fixes for kernels less than or equal to patchlevel 10.
  345. ---
  346. > A small bug fix for kernels less than or equal to patchlevel 10.
  347. 5,17c5,9
  348. <     1. In the current code, select() on a pipe returns true (ie data
  349. <        available) if there are no reader/writers.  In the case of
  350. <        named pipes (FIFOs), it is quite permissible for there to be
  351. <        no reader/writers, and select() should block until data is
  352. <        available.  In the case of normal pipes, exfds can be used to
  353. <        check for pipes that have no reader/writers.
  354. <     2. The nice call doesn't do high boundary checking.  This causes
  355. <        the reccommended method for setting a nice value to 0 to
  356. <        fail {nice(-40); nice(20); nice(0);}.  Also note that the
  357. <        nice limits are now 1 to 35, not the normal U*X values of
  358. <        0 to 39, values determined by the choice of PZERO - the man
  359. <        page should be updated.  And ps prints the nice value with
  360. <        the wrong sign.
  361. ---
  362. > In the current code, select() on a pipe returns true (ie data available)
  363. > if there are no reader/writers.  In the case of named pipes (FIFOs), it
  364. > is quite permissible for there to be no reader/writers, and select()
  365. > should block until data is available.  Similar exceptions apply to
  366. > reads/writes.
  367. 18a11,29
  368. > *** fs/fifo.c.orig    Wed Mar 31 20:08:45 1993
  369. > --- fs/fifo.c    Wed Jul 14 08:29:38 1993
  370. > ***************
  371. > *** 156,162 ****
  372. >   void init_fifo(struct inode * inode)
  373. >   {
  374. >       inode->i_op = &fifo_inode_operations;
  375. > !     inode->i_pipe = 1;
  376. >       PIPE_BASE(*inode) = NULL;
  377. >       PIPE_HEAD(*inode) = PIPE_TAIL(*inode) = 0;
  378. >       PIPE_RD_OPENERS(*inode) = PIPE_WR_OPENERS(*inode) = 0;
  379. > --- 156,162 ----
  380. >   void init_fifo(struct inode * inode)
  381. >   {
  382. >       inode->i_op = &fifo_inode_operations;
  383. > !     inode->i_pipe = 2;
  384. >       PIPE_BASE(*inode) = NULL;
  385. >       PIPE_HEAD(*inode) = PIPE_TAIL(*inode) = 0;
  386. >       PIPE_RD_OPENERS(*inode) = PIPE_WR_OPENERS(*inode) = 0;
  387. 20c31
  388. < --- fs/pipe.c    Sun May 23 01:13:43 1993
  389. ---
  390. > --- fs/pipe.c    Thu Jul 15 00:43:26 1993
  391. 21a33,83
  392. > *** 20,26 ****
  393. >       if (!(filp->f_flags & O_NONBLOCK))
  394. >           while (!PIPE_SIZE(*inode)) {
  395. >               wake_up(& PIPE_WRITE_WAIT(*inode));
  396. > !             if (!PIPE_WRITERS(*inode)) /* are there any writers? */
  397. >                   return 0;
  398. >               if (current->signal & ~current->blocked)
  399. >                   return -ERESTARTSYS;
  400. > --- 20,26 ----
  401. >       if (!(filp->f_flags & O_NONBLOCK))
  402. >           while (!PIPE_SIZE(*inode)) {
  403. >               wake_up(& PIPE_WRITE_WAIT(*inode));
  404. > !             if (inode->i_pipe == 1 && !PIPE_WRITERS(*inode)) /* are there any writers? */
  405. >                   return 0;
  406. >               if (current->signal & ~current->blocked)
  407. >                   return -ERESTARTSYS;
  408. > ***************
  409. > *** 51,57 ****
  410. >   {
  411. >       int chars, size, written = 0;
  412. >   
  413. > !     if (!PIPE_READERS(*inode)) { /* no readers */
  414. >           send_sig(SIGPIPE,current,0);
  415. >           return -EPIPE;
  416. >       }
  417. > --- 51,57 ----
  418. >   {
  419. >       int chars, size, written = 0;
  420. >   
  421. > !     if (inode->i_pipe == 1 && !PIPE_READERS(*inode)) { /* no readers */
  422. >           send_sig(SIGPIPE,current,0);
  423. >           return -EPIPE;
  424. >       }
  425. > ***************
  426. > *** 62,68 ****
  427. >           size = PAGE_SIZE-1;
  428. >       while (count>0) {
  429. >           while (PIPE_SIZE(*inode) >= size) {
  430. > !             if (!PIPE_READERS(*inode)) { /* no readers */
  431. >                   send_sig(SIGPIPE,current,0);
  432. >                   return written?written:-EPIPE;
  433. >               }
  434. > --- 62,68 ----
  435. >           size = PAGE_SIZE-1;
  436. >       while (count>0) {
  437. >           while (PIPE_SIZE(*inode) >= size) {
  438. > !             if (inode->i_pipe == 1 && !PIPE_READERS(*inode)) { /* no readers */
  439. >                   send_sig(SIGPIPE,current,0);
  440. >                   return written?written:-EPIPE;
  441. >               }
  442. > ***************
  443. 39c101
  444. < !             if (!PIPE_EMPTY(*inode))
  445. ---
  446. > !             if (!PIPE_EMPTY(*inode) || (inode->i_pipe == 1 && !PIPE_WRITERS(*inode)))
  447. 44c106
  448. < !             if (!PIPE_FULL(*inode))
  449. ---
  450. > !             if (!PIPE_FULL(*inode) || (inode->i_pipe == 1 && !PIPE_READERS(*inode)))
  451. 48,72d109
  452. < *** kernel/sched.c.orig    Sat Apr 24 09:52:29 1993
  453. < --- kernel/sched.c    Tue Jun 22 23:58:12 1993
  454. < ***************
  455. < *** 504,512 ****
  456. <   {
  457. <       if (increment < 0 && !suser())
  458. <           return -EPERM;
  459. < -     if (increment >= current->priority)
  460. < -         increment = current->priority-1;
  461. <       current->priority -= increment;
  462. <       return 0;
  463. <   }
  464. <   
  465. < --- 504,514 ----
  466. <   {
  467. <       if (increment < 0 && !suser())
  468. <           return -EPERM;
  469. <       current->priority -= increment;
  470. < +     if (current->priority < 1)
  471. < +         current->priority = 1;
  472. < +     if (current->priority > 35)
  473. < +         current->priority = 35;
  474. <       return 0;
  475. <   }
  476. <   
  477. EOF-EOF-EOF
  478. RmFile port/linux/osfcn.h
  479. Patch port/linux/paths.h<<'EOF-EOF-EOF'
  480. 4c4
  481. < #include </usr/include/paths.h>
  482. ---
  483. > #include_next <paths.h>
  484. EOF-EOF-EOF
  485. RmFile port/linux/sys/param.h
  486. NewFile port/linux/sys/types.h<<'EOF-EOF-EOF'
  487. #include_next <sys/types.h>
  488. /*
  489.  * Macros for counting and rounding.
  490.  */
  491. #ifndef howmany
  492. #define    howmany(x, y)    (((x)+((y)-1))/(y))
  493. #endif
  494. EOF-EOF-EOF
  495. Patch recvfax/main.c<<'EOF-EOF-EOF'
  496. 1c1
  497. < /*    $Header: /usr/people/sam/fax/recvfax/RCS/main.c,v 1.38 93/07/08 17:06:27 sam Exp $
  498. ---
  499. > /*    $Header: /usr/people/sam/fax/recvfax/RCS/main.c,v 1.39 93/07/16 10:17:07 sam Exp $
  500. 89c89
  501. < #ifdef SO_LINGER
  502. ---
  503. > #if defined(SO_LINGER) && !defined(__linux__)
  504. EOF-EOF-EOF
  505. Patch util/FaxClient.c++<<'EOF-EOF-EOF'
  506. 1c1
  507. < /*    $Header: /usr/people/sam/fax/util/RCS/FaxClient.c++,v 1.27 93/07/08 16:49:15 sam Exp $
  508. ---
  509. > /*    $Header: /usr/people/sam/fax/util/RCS/FaxClient.c++,v 1.28 93/07/16 10:29:53 sam Exp $
  510. 267a268,277
  511. > #ifdef __linux__
  512. >     /*
  513. >      * Linux kernel bug: can get short writes on
  514. >      * stream sockets when setup for blocking i/o.
  515. >      */
  516. >     cc -= n;
  517. >     for (int cnt, sent = 0; n; sent += cnt, n -= cnt) 
  518. >         if ((cnt = write(fdOut, buf + sent, n)) <= 0)
  519. >             fxFatal("Protocol botch (data write).");
  520. > #else
  521. 270a281
  522. > #endif
  523. EOF-EOF-EOF
  524. Patch util/Makefile<<'EOF-EOF-EOF'
  525. 2c2
  526. < #    $Header: /usr/people/sam/fax/util/RCS/Makefile,v 1.52 93/07/09 18:27:41 sam Exp $
  527. ---
  528. > #    $Header: /usr/people/sam/fax/util/RCS/Makefile,v 1.53 93/07/19 11:34:17 sam Exp $
  529. 102a103,104
  530. >     ${PUTSERV} -F ${SPOOL}/bin -src xferstats.sh -O xferstats
  531. >     ${PUTSERV} -F ${SPOOL}/bin -src recvstats.sh -O recvstats
  532. EOF-EOF-EOF
  533. Patch util/SendFaxClient.c++<<'EOF-EOF-EOF'
  534. 1c1
  535. < /*    $Header: /usr/people/sam/fax/util/RCS/SendFaxClient.c++,v 1.8 93/06/18 11:44:20 sam Exp $
  536. ---
  537. > /*    $Header: /usr/people/sam/fax/util/RCS/SendFaxClient.c++,v 1.9 93/07/16 10:29:56 sam Exp $
  538. 39a40
  539. > #ifndef __linux__
  540. 40a42
  541. > #endif
  542. EOF-EOF-EOF
  543. Patch util/ps2fax.gs.sh<<'EOF-EOF-EOF'
  544. 2c2
  545. < #    $Header: /usr/people/sam/fax/util/RCS/ps2fax.gs.sh,v 1.9 93/07/08 16:48:33 sam Exp $
  546. ---
  547. > #    $Header: /usr/people/sam/fax/util/RCS/ps2fax.gs.sh,v 1.10 93/07/16 10:30:03 sam Exp $
  548. 43c43
  549. < opt=
  550. ---
  551. > out=ps.fax        # default output filename
  552. 50c50
  553. <     -o)    shift; opt="$opt -sOutputFile=$1" ;;
  554. ---
  555. >     -o)    shift; out="$1" ;;
  556. 60,65c60,68
  557. < # 279.4mm is actually correct, but many people round up!
  558. < 1728x280|1728x279) paper=letter;;
  559. < *x297) paper=a4;;
  560. < *x364) paper=b4;;
  561. < *)    echo "$0: Unsupported page size: $pagewidth x $pagelength";
  562. <     exit 1;;
  563. ---
  564. > 1728x280|1728x279)        # 279.4mm is actually correct...
  565. >     paper=letter;;
  566. > *x296|*x297)            # more roundoff problems...
  567. >     paper=a4;;
  568. > *x364)
  569. >     paper=b4;;
  570. > *)
  571. >     echo "$0: Unsupported page size: $pagewidth x $pagelength";
  572. >     exit 1;;
  573. 68c71
  574. <     -sPAPERSIZE=$paper -r204x$vres -dSAFER=true $opt -
  575. ---
  576. >     -sPAPERSIZE=$paper -r204x$vres -dSAFER=true "-sOutputFile=$out" -
  577. EOF-EOF-EOF
  578. NewFile util/recvstats.sh<<'EOF-EOF-EOF'
  579. #! /bin/sh
  580. #    $Header: /usr/people/sam/fax/util/RCS/recvstats.sh,v 1.2 93/07/19 11:56:57 sam Exp $
  581. #
  582. # FlexFAX Facsimile Software
  583. #
  584. # Copyright (c) 1990, 1991, 1992, 1993 Sam Leffler
  585. # Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
  586. # Permission to use, copy, modify, distribute, and sell this software and 
  587. # its documentation for any purpose is hereby granted without fee, provided
  588. # that (i) the above copyright notices and this permission notice appear in
  589. # all copies of the software and related documentation, and (ii) the names of
  590. # Sam Leffler and Silicon Graphics may not be used in any advertising or
  591. # publicity relating to the software without the specific, prior written
  592. # permission of Sam Leffler and Silicon Graphics.
  593. # THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  594. # EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  595. # WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  596. # IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  597. # ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  598. # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  599. # WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
  600. # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
  601. # OF THIS SOFTWARE.
  602. #
  603.  
  604. #
  605. # Print Statistics about Received Facsimile.
  606. #
  607. SPOOL=/usr/spool/fax
  608. AWK=nawk
  609.  
  610. PATH=/bin:/usr/bin:/etc
  611. test -d /usr/ucb  && PATH=$PATH:/usr/ucb        # Sun and others
  612. test -d /usr/bsd  && PATH=$PATH:/usr/bsd        # Silicon Graphics
  613. test -d /usr/5bin && PATH=/usr/5bin:$PATH:/usr/etc    # Sun and others
  614. test -d /usr/sbin && PATH=/usr/sbin:$PATH        # 4.4BSD-derived
  615.  
  616. FILES=
  617. SORTKEY=-sender
  618.  
  619. while [ x"$1" != x"" ] ; do
  620.     case $1 in
  621.     -send*|-csi|-dest*|-speed|-rate|-format)
  622.         SORTKEY=$1;;
  623.     -*)        echo "Usage: $0 [-sortkey] [files]"; exit 1;;
  624.     *)        FILES="$FILES $1";;
  625.     esac
  626.     shift
  627. done
  628. if [ -z "$FILES" ]; then
  629.     FILES=$SPOOL/etc/xferlog
  630. fi
  631.  
  632. #
  633. # Construct awk rules to collect information according
  634. # to the desired sort key.  There are two rules for
  635. # each; to deal with the two different formats that
  636. # have existed over time.
  637. #
  638. case $SORTKEY in
  639. -send*|-csi)
  640.     AWKRULES='$2 == "RECV" && NF == 9  { acct($3, $7, $8, $5, $6, $9); }
  641.                $2 == "RECV" && NF == 11 { acct($6, $9, $10, $7, $8, $11); }'
  642.     ;;
  643. -dest*)
  644.     AWKRULES='$2 == "RECV" && NF == 9  { acct($4, $7, $8, $5, $6, $9); }
  645.               $2 == "RECV" && NF == 11 { acct($5, $9, $10, $7, $8, $11); }'
  646.     ;;
  647. -speed|-rate)
  648.     AWKRULES='$2 == "RECV" && NF == 9  { acct($5, $7, $8, $5, $6, $9); }
  649.               $2 == "RECV" && NF == 11 { acct($7, $9, $10, $7, $8, $11); }'
  650.     ;;
  651. -format)
  652.     AWKRULES='$2 == "RECV" && NF == 9  { acct($6, $7, $8, $5, $6, $9); }
  653.               $2 == "RECV" && NF == 11 { acct($8, $9, $10, $7, $8, $11); }'
  654.     ;;
  655. esac
  656.  
  657. #
  658. # Generate an awk program to process the statistics file.
  659. #
  660. tmpAwk=/tmp/xfer$$
  661. trap "rm -f $tmpAwk; exit 1" 0 1 2 15
  662.  
  663. (cat<<'EOF'
  664. #
  665. # Convert hh:mm:ss to minutes.
  666. #
  667. func cvtTime(s)
  668. {
  669.     t = 0;
  670.     for (n = split(s, a, ":"); n > 1; n--)
  671.     t = t*60 + a[n];
  672.     if (n > 0)
  673.     t += t/60;
  674.     return t;
  675. }
  676.  
  677. func setupDigits()
  678. {
  679.   digits[0] = "0"; digits[1] = "1"; digits[2] = "2";
  680.   digits[3] = "3"; digits[4] = "4"; digits[5] = "5";
  681.   digits[6] = "6"; digits[7] = "7"; digits[8] = "8";
  682.   digits[9] = "9";
  683. }
  684.  
  685. #
  686. # Format seconds as hh:mm:ss.
  687. #
  688. func fmtTime(t)
  689. {
  690.     v = int(t/3600);
  691.     result = "";
  692.     if (v > 0) {
  693.     if (v >= 10)
  694.         result = digits[int(v/10)];
  695.     result = result digits[int(v%10)] ":";
  696.     t -= v*3600;
  697.     }
  698.     v = int(t/60);
  699.     if (v >= 10 || result != "")
  700.     result = result digits[int(v/10)];
  701.     result = result digits[int(v%10)];
  702.     t -= v*60;
  703.     return (result ":" digits[int(t/10)] digits[int(t%10)]);
  704. }
  705.  
  706. #
  707. # Setup a map for histogram calculations.
  708. #
  709. func setupMap(s, map)
  710. {
  711.     n = split(s, a, ":");
  712.     for (i = 1; i <= n; i++)
  713.     map[a[i]] = i;
  714. }
  715.  
  716. #
  717. # Add pages to a histogram.
  718. #
  719. func addToMap(key, ix, pages, map)
  720. {
  721.     if (key == "") {
  722.     for (i in map)
  723.         key = key ":";
  724.     }
  725.     n = split(key, a, ":");
  726.     a[map[ix]] += pages;
  727.     t = a[1];
  728.     for (i = 2; i <= n; i++)
  729.       t = t ":" a[i];
  730.     return t;
  731. }
  732.  
  733. #
  734. # Return the name of the item with the
  735. # largest number of accumulated pages.
  736. #
  737. func bestInMap(totals, map)
  738. {
  739.    n = split(totals, a, ":");
  740.    imax = 1; max = -1;
  741.    for (j = 1; j <= n; j++)
  742.        if (a[j] > max) {
  743.        max = a[j];
  744.        imax = j;
  745.        }
  746.    split(map, a, ":");
  747.    return a[imax];
  748. }
  749.  
  750. #
  751. # Sort array a[l..r]
  752. #
  753. function qsort(a, l, r) {
  754.     i = l;
  755.     k = r+1;
  756.     item = a[l];
  757.     for (;;) {
  758.     while (i < r) {
  759.             i++;
  760.         if (a[i] >= item)
  761.         break;
  762.         }
  763.     while (k > l) {
  764.             k--;
  765.         if (a[k] <= item)
  766.         break;
  767.         }
  768.         if (i >= k)
  769.         break;
  770.     t = a[i]; a[i] = a[k]; a[k] = t;
  771.     }
  772.     t = a[l]; a[l] = a[k]; a[k] = t;
  773.     if (k != 0 && l < k-1)
  774.     qsort(a, l, k-1);
  775.     if (k+1 < r)
  776.     qsort(a, k+1, r);
  777. }
  778.  
  779. #
  780. # Accumulate a statistics record.
  781. #
  782. func acct(key, pages, time, br, df, status)
  783. {
  784.     gsub("\"", "", key);
  785.     gsub("^ +", "", key);
  786.     gsub(" +$", "", key);
  787.     recvpages[key] += pages;
  788.     if (pages == 0 && time > 60)
  789.     time = 0;
  790.     recvtime[key] += time;
  791.     gsub("\"", "", status);
  792.     if (status != "")
  793.     recverrs[key]++;
  794.     gsub("\"", "", br);
  795.     recvrate[key] = addToMap(recvrate[key], br, pages, rateMap);
  796.     gsub("\"", "", df);
  797.     recvdata[key] = addToMap(recvdata[key], df, pages, dataMap);
  798. }
  799.  
  800. #
  801. # Print a rule between the stats and the totals line.
  802. #
  803. func printRule(n, s)
  804. {
  805.     r = "";
  806.     while (n-- >= 0)
  807.     r = r s;
  808.     printf "%s\n", r;
  809. }
  810.  
  811. BEGIN        { FS="\t";
  812.           rates = "2400:4800:7200:9600:12000:14400";
  813.           setupMap(rates, rateMap);
  814.           datas = "1-D MR:2-D MR:2-D Uncompressed Mode:2-D MMR";
  815.           setupMap(datas, dataMap);
  816.         }
  817. END        { OFS="\t"; setupDigits();
  818.           maxlen = 15;
  819.           nsorted = 0;
  820.           for (i in recvpages) {
  821.               l = length(i);
  822.               if (l > maxlen)
  823.             maxlen = l;
  824.               sorted[nsorted++] = i;
  825.           }
  826.           qsort(sorted, 0, nsorted-1);
  827.           fmt = "%-" maxlen "." maxlen "s";    # e.g. %-24.24s
  828.           printf fmt " %5s %8s %6s %4s %7s %7s\n",
  829.               "Sender", "Pages", "Time", "Pg/min",
  830.               "Errs", "TypRate", "TypData";
  831.           tpages = 0;
  832.           ttime = 0;
  833.           terrs = 0;
  834.           for (k = 0; k < nsorted; k++) {
  835.               i = sorted[k];
  836.               t = recvtime[i]; if (t == 0) t = 1;
  837.               n = recvpages[i]; if (n == 0) n = 1;
  838.               brate = best
  839.               printf fmt " %5d %8s %6.1f %4d %7d %7s\n",
  840.               i, recvpages[i], fmtTime(recvtime[i]*60),
  841.               recvpages[i] / t, recverrs[i],
  842.               bestInMap(recvrate[i], rates),
  843.               bestInMap(recvdata[i], datas);
  844.             tpages += recvpages[i];
  845.             ttime += recvtime[i];
  846.             terrs += recverrs[i];
  847.           }
  848.           printRule(maxlen+1+5+1+8+6+1+4+1+7+1+7, "-");
  849.           t = ttime; if (t == 0) t = 1;
  850.           printf fmt " %5d %8s %6.1f %4d\n",
  851.               "Total", tpages, fmtTime(ttime*60), tpages/t, terrs;
  852.         }
  853. EOF
  854. echo "$AWKRULES"
  855. )>$tmpAwk
  856. $AWK -f $tmpAwk $FILES
  857. EOF-EOF-EOF
  858. RmFile util/xfer.awk
  859. RmFile util/xferdest.awk
  860. NewFile util/xferstats.sh<<'EOF-EOF-EOF'
  861. #! /bin/sh
  862. #    $Header: /usr/people/sam/fax/util/RCS/xferstats.sh,v 1.2 93/07/19 11:56:59 sam Exp $
  863. #
  864. # FlexFAX Facsimile Software
  865. #
  866. # Copyright (c) 1990, 1991, 1992, 1993 Sam Leffler
  867. # Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
  868. # Permission to use, copy, modify, distribute, and sell this software and 
  869. # its documentation for any purpose is hereby granted without fee, provided
  870. # that (i) the above copyright notices and this permission notice appear in
  871. # all copies of the software and related documentation, and (ii) the names of
  872. # Sam Leffler and Silicon Graphics may not be used in any advertising or
  873. # publicity relating to the software without the specific, prior written
  874. # permission of Sam Leffler and Silicon Graphics.
  875. # THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  876. # EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  877. # WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  878. # IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  879. # ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  880. # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  881. # WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
  882. # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
  883. # OF THIS SOFTWARE.
  884. #
  885.  
  886. #
  887. # Print Statistics about Transmitted Facsimile.
  888. #
  889. SPOOL=/usr/spool/fax
  890. AWK=nawk
  891.  
  892. PATH=/bin:/usr/bin:/etc
  893. test -d /usr/ucb  && PATH=$PATH:/usr/ucb        # Sun and others
  894. test -d /usr/bsd  && PATH=$PATH:/usr/bsd        # Silicon Graphics
  895. test -d /usr/5bin && PATH=/usr/5bin:$PATH:/usr/etc    # Sun and others
  896. test -d /usr/sbin && PATH=/usr/sbin:$PATH        # 4.4BSD-derived
  897.  
  898. FILES=
  899. SORTKEY=-sender
  900.  
  901. while [ x"$1" != x"" ] ; do
  902.     case $1 in
  903.     -send*|-csi|-dest*|-speed|-rate|-format)
  904.         SORTKEY=$1;;
  905.     -*)        echo "Usage: $0 [-sortkey] [files]"; exit 1;;
  906.     *)        FILES="$FILES $1";;
  907.     esac
  908.     shift
  909. done
  910. if [ -z "$FILES" ]; then
  911.     FILES=$SPOOL/etc/xferlog
  912. fi
  913.  
  914. #
  915. # Construct awk rules to collect information according
  916. # to the desired sort key.  There are two rules for
  917. # each; to deal with the two different formats that
  918. # have existed over time.
  919. #
  920. case $SORTKEY in
  921. -send*)
  922.     AWKRULES='$2 == "SEND" && NF == 9  { acct($3, $7, $8, $5, $6, $9); }
  923.                $2 == "SEND" && NF == 11 { acct($4, $9, $10, $7, $8, $11); }'
  924.     ;;
  925. -csi)
  926.     AWKRULES='$2 == "SEND" && NF == 9  { acct($4, $7, $8, $5, $6, $9); }
  927.               $2 == "SEND" && NF == 11 { acct($6, $9, $10, $7, $8, $11); }'
  928.     ;;
  929. -dest*)
  930.     AWKRULES='$2 == "SEND" && NF == 9  { acct($4, $7, $8, $5, $6, $9); }
  931.               $2 == "SEND" && NF == 11 { acct($5, $9, $10, $7, $8, $11); }'
  932.     ;;
  933. -speed|-rate)
  934.     AWKRULES='$2 == "SEND" && NF == 9  { acct($5, $7, $8, $5, $6, $9); }
  935.               $2 == "SEND" && NF == 11 { acct($7, $9, $10, $7, $8, $11); }'
  936.     ;;
  937. -format)
  938.     AWKRULES='$2 == "SEND" && NF == 9  { acct($6, $7, $8, $5, $6, $9); }
  939.               $2 == "SEND" && NF == 11 { acct($8, $9, $10, $7, $8, $11); }'
  940.     ;;
  941. esac
  942.  
  943. #
  944. # Generate an awk program to process the statistics file.
  945. #
  946. tmpAwk=/tmp/xfer$$
  947. trap "rm -f $tmpAwk; exit 1" 0 1 2 15
  948.  
  949. (cat<<'EOF'
  950. #
  951. # Convert hh:mm:ss to minutes.
  952. #
  953. func cvtTime(s)
  954. {
  955.     t = 0;
  956.     for (n = split(s, a, ":"); n > 1; n--)
  957.     t = t*60 + a[n];
  958.     if (n > 0)
  959.     t += t/60;
  960.     return t;
  961. }
  962.  
  963. func setupDigits()
  964. {
  965.   digits[0] = "0"; digits[1] = "1"; digits[2] = "2";
  966.   digits[3] = "3"; digits[4] = "4"; digits[5] = "5";
  967.   digits[6] = "6"; digits[7] = "7"; digits[8] = "8";
  968.   digits[9] = "9";
  969. }
  970.  
  971. #
  972. # Format seconds as hh:mm:ss.
  973. #
  974. func fmtTime(t)
  975. {
  976.     v = int(t/3600);
  977.     result = "";
  978.     if (v > 0) {
  979.     if (v >= 10)
  980.         result = digits[int(v/10)];
  981.     result = result digits[int(v%10)] ":";
  982.     t -= v*3600;
  983.     }
  984.     v = int(t/60);
  985.     if (v >= 10 || result != "")
  986.     result = result digits[int(v/10)];
  987.     result = result digits[int(v%10)];
  988.     t -= v*60;
  989.     return (result ":" digits[int(t/10)] digits[int(t%10)]);
  990. }
  991.  
  992. #
  993. # Setup a map for histogram calculations.
  994. #
  995. func setupMap(s, map)
  996. {
  997.     n = split(s, a, ":");
  998.     for (i = 1; i <= n; i++)
  999.     map[a[i]] = i;
  1000. }
  1001.  
  1002. #
  1003. # Add pages to a histogram.
  1004. #
  1005. func addToMap(key, ix, pages, map)
  1006. {
  1007.     if (key == "") {
  1008.     for (i in map)
  1009.         key = key ":";
  1010.     }
  1011.     n = split(key, a, ":");
  1012.     a[map[ix]] += pages;
  1013.     t = a[1];
  1014.     for (i = 2; i <= n; i++)
  1015.       t = t ":" a[i];
  1016.     return t;
  1017. }
  1018.  
  1019. #
  1020. # Return the name of the item with the
  1021. # largest number of accumulated pages.
  1022. #
  1023. func bestInMap(totals, map)
  1024. {
  1025.    n = split(totals, a, ":");
  1026.    imax = 1; max = -1;
  1027.    for (j = 1; j <= n; j++)
  1028.        if (a[j] > max) {
  1029.        max = a[j];
  1030.        imax = j;
  1031.        }
  1032.    split(map, a, ":");
  1033.    return a[imax];
  1034. }
  1035.  
  1036. #
  1037. # Sort array a[l..r]
  1038. #
  1039. function qsort(a, l, r) {
  1040.     i = l;
  1041.     k = r+1;
  1042.     item = a[l];
  1043.     for (;;) {
  1044.     while (i < r) {
  1045.             i++;
  1046.         if (a[i] >= item)
  1047.         break;
  1048.         }
  1049.     while (k > l) {
  1050.             k--;
  1051.         if (a[k] <= item)
  1052.         break;
  1053.         }
  1054.         if (i >= k)
  1055.         break;
  1056.     t = a[i]; a[i] = a[k]; a[k] = t;
  1057.     }
  1058.     t = a[l]; a[l] = a[k]; a[k] = t;
  1059.     if (k != 0 && l < k-1)
  1060.     qsort(a, l, k-1);
  1061.     if (k+1 < r)
  1062.     qsort(a, k+1, r);
  1063. }
  1064.  
  1065. #
  1066. # Accumulate a statistics record.
  1067. #
  1068. func acct(key, pages, time, br, df, status)
  1069. {
  1070.     gsub("\"", "", key);
  1071.     gsub("^ +", "", key);
  1072.     gsub(" +$", "", key);
  1073.     sendpages[key] += pages;
  1074.     if (pages == 0 && time > 60)
  1075.     time = 0;
  1076.     sendtime[key] += time;
  1077.     gsub("\"", "", status);
  1078.     if (status != "")
  1079.     senderrs[key]++;
  1080.     gsub("\"", "", br);
  1081.     sendrate[key] = addToMap(sendrate[key], br, pages, rateMap);
  1082.     gsub("\"", "", df);
  1083.     senddata[key] = addToMap(senddata[key], df, pages, dataMap);
  1084. }
  1085.  
  1086. #
  1087. # Print a rule between the stats and the totals line.
  1088. #
  1089. func printRule(n, s)
  1090. {
  1091.     r = "";
  1092.     while (n-- >= 0)
  1093.     r = r s;
  1094.     printf "%s\n", r;
  1095. }
  1096.  
  1097. BEGIN        { FS="\t";
  1098.           rates = "2400:4800:7200:9600:12000:14400";
  1099.           setupMap(rates, rateMap);
  1100.           datas = "1-D MR:2-D MR:2-D Uncompressed Mode:2-D MMR";
  1101.           setupMap(datas, dataMap);
  1102.         }
  1103. END        { OFS="\t"; setupDigits();
  1104.           maxlen = 15;
  1105.           nsorted = 0;
  1106.           for (i in sendpages) {
  1107.               l = length(i);
  1108.               if (l > maxlen)
  1109.             maxlen = l;
  1110.               sorted[nsorted++] = i;
  1111.           }
  1112.           qsort(sorted, 0, nsorted-1);
  1113.           fmt = "%-" maxlen "." maxlen "s";    # e.g. %-24.24s
  1114.           printf fmt " %5s %8s %6s %4s %7s %7s\n",
  1115.               "Destination", "Pages", "Time", "Pg/min",
  1116.               "Errs", "TypRate", "TypData";
  1117.           tpages = 0;
  1118.           ttime = 0;
  1119.           terrs = 0;
  1120.           for (k = 0; k < nsorted; k++) {
  1121.               i = sorted[k];
  1122.               t = sendtime[i]; if (t == 0) t = 1;
  1123.               n = sendpages[i]; if (n == 0) n = 1;
  1124.               brate = best
  1125.               printf fmt " %5d %8s %6.1f %4d %7d %7.7s\n",
  1126.               i, sendpages[i], fmtTime(sendtime[i]*60),
  1127.               sendpages[i] / t, senderrs[i],
  1128.               bestInMap(sendrate[i], rates),
  1129.               bestInMap(senddata[i], datas);
  1130.             tpages += sendpages[i];
  1131.             ttime += sendtime[i];
  1132.             terrs += senderrs[i];
  1133.           }
  1134.           printRule(maxlen+1+5+1+8+6+1+4+1+7+1+7, "-");
  1135.           t = ttime; if (t == 0) t = 1;
  1136.           printf fmt " %5d %8s %6.1f %4d\n",
  1137.               "Total", tpages, fmtTime(ttime*60), tpages/t, terrs;
  1138.         }
  1139. EOF
  1140. echo "$AWKRULES"
  1141. )>$tmpAwk
  1142. $AWK -f $tmpAwk $FILES
  1143. EOF-EOF-EOF
  1144.